package com.doit.day01;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;
import java.util.Map;
import java.util.Set;

public class _03_查询名称空间 {
    public static void main(String[] args) throws IOException {
        Configuration conf = HBaseConfiguration.create();
        //设置参数
        conf.set("hbase.zookeeper.quorum","linux01:2181,linux02:2181,linux03:2181");
        //创建连接对象
        Connection conn = ConnectionFactory.createConnection(conf);
        //获取连接对象
        Admin admin = conn.getAdmin();
        //列出所有的namespace
        //先要获取到名称空间的描述器
        NamespaceDescriptor[] namespaceDescriptors = admin.listNamespaceDescriptors();
        for (NamespaceDescriptor namespaceDescriptor : namespaceDescriptors) {
            String namespace = namespaceDescriptor.getName();
            System.out.println(namespace);
            System.out.println("------------帅气的分隔符---------------");
            Map<String, String> configuration = namespaceDescriptor.getConfiguration();
            Set<String> keys = configuration.keySet();
            for (String key : keys) {
                String value = configuration.get(key);
                System.out.println(key+"=>"+value);
            }
        }


    }
}
